package com.mercenary.wein.screenControl.bean;

import com.google.gson.Gson;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by tuxiao on 2017/3/20.
 */
public class CommandBean {
    private int actionId;
    private String content;
    private String serialNo;
    private String submitTime;
    private int port;
    private String exe_mode;
    private ExeModeBean exeModeBean;
    private String filePaths;
    private long zid;

    public long getZid() {
        return zid;
    }

    public void setZid(long zid) {
        this.zid = zid;
    }

    public String getFilePaths() {
        return filePaths;
    }

    public void setFilePaths(String filePaths) {
        this.filePaths = filePaths;
    }

    public String getExe_mode() {
        return exe_mode;
    }

    public void setExe_mode(String exe_mode) {
        this.exe_mode = exe_mode;
        this.exeModeBean = new Gson().fromJson(exe_mode,ExeModeBean.class);
    }


    public ExeModeBean getExeModeBean() {
        if(exeModeBean==null)return new ExeModeBean();
        return exeModeBean;
    }

    public void setExeModeBean(ExeModeBean exeModeBean) {
        this.exeModeBean = exeModeBean;
        this.exe_mode = exeModeBean.toJson();
    }

    public int getPort() {
        return port;
    }

    public void setPort(int port) {
        this.port = port;
    }

    public int getActionId() {
        return actionId;
    }

    public void setActionId(int actionId) {
        this.actionId = actionId;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getSerialNo() {
        return serialNo;
    }

    public void setSerialNo(String serialNo) {
        this.serialNo = serialNo;
    }

    public String getSubmitTime() {
        return new SimpleDateFormat("yyyyMMdd HH:mm:ss").format(new Date());
    }

    public void setSubmitTime(String submitTime) {
        this.submitTime = submitTime;
    }

    public Date getExeDate(){
        try {
            return exeModeBean.getExeDate();
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return null;
    }

    public int getInterval(){
        return exeModeBean.getInterval();
    }

    public int getTimeUnit(){
        return exeModeBean.getTimeUnit();
    }


    public CommandBean(int actionId, String content, String serialNo,  int port) {
        this.actionId = actionId;
        this.content = content;
        this.serialNo = serialNo;
        this.port = port;
    }

    public String toJson(){
        return new Gson().toJson(this);
    }
}
